//package io.dbw.modules.business.controller.sys;
//
//
//import io.dbw.common.utils.PageUtils;
//import io.dbw.modules.quartz.JobDetails;
//import io.dbw.modules.quartz.QuartzManager;
//import io.swagger.annotations.Api;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.quartz.QuartzJobBean;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.HashMap;
//import java.util.Map;
//
//
///**
// * @author pdai
// */
//@RestController
//@RequestMapping(value = "/sys/job")
//@Api(tags = "定时任务")
//public class SysJobController {
//
//    @Autowired
//    private QuartzManager qtzManager;
//
//    @SuppressWarnings("unchecked")
//    private static Class<? extends QuartzJobBean> getClass(String classname) throws Exception {
//        Class<?> class1 = Class.forName(classname);
//        return (Class<? extends QuartzJobBean>) class1;
//    }
//
//    /**
//     * @param jobClassName
//     * @param jobGroupName
//     * @param cronExpression
//     * @throws Exception
//     */
//    @PostMapping(value = "/addjob")
//    public void addjob(@RequestParam(value = "jobClassName") String jobClassName,
//                       @RequestParam(value = "jobGroupName") String jobGroupName,
//                       @RequestParam(value = "cronExpression") String cronExpression) throws Exception {
//        qtzManager.addOrUpdateJob(getClass(jobClassName), jobClassName, jobGroupName, cronExpression);
//    }
//
//    /**
//     * @param jobClassName
//     * @param jobGroupName
//     * @throws Exception
//     */
//    @PostMapping(value = "/pausejob")
//    public void pausejob(@RequestParam(value = "jobClassName") String jobClassName,
//                         @RequestParam(value = "jobGroupName") String jobGroupName) throws Exception {
//        qtzManager.pauseJob(jobClassName, jobGroupName);
//    }
//
//    /**
//     * @param jobClassName
//     * @param jobGroupName
//     * @throws Exception
//     */
//    @PostMapping(value = "/resumejob")
//    public void resumejob(@RequestParam(value = "jobClassName") String jobClassName,
//                          @RequestParam(value = "jobGroupName") String jobGroupName) throws Exception {
//        qtzManager.resumeJob(jobClassName, jobGroupName);
//    }
//
//    /**
//     * @param jobClassName
//     * @param jobGroupName
//     * @param cronExpression
//     * @throws Exception
//     */
//    @PostMapping(value = "/reschedulejob")
//    public void rescheduleJob(@RequestParam(value = "jobClassName") String jobClassName,
//                              @RequestParam(value = "jobGroupName") String jobGroupName,
//                              @RequestParam(value = "cronExpression") String cronExpression) throws Exception {
//        qtzManager.addOrUpdateJob(getClass(jobClassName), jobClassName, jobGroupName, cronExpression);
//    }
//
//    /**
//     * @param jobClassName
//     * @param jobGroupName
//     * @throws Exception
//     */
//    @PostMapping(value = "/deletejob")
//    public void deletejob(@RequestParam(value = "jobClassName") String jobClassName,
//                          @RequestParam(value = "jobGroupName") String jobGroupName) throws Exception {
//        qtzManager.deleteJob(jobClassName, jobGroupName);
//    }
//
//    /**
//     * @param pageNum
//     * @param pageSize
//     * @return
//     */
//    @GetMapping(value = "/queryjob")
//    public Map<String, Object> queryjob(@RequestParam(value = "pageNum") Integer pageNum,
//                                        @RequestParam(value = "pageSize") Integer pageSize) {
//        PageUtils<JobDetails> jobAndTrigger = qtzManager.queryAllJobBean(pageNum, pageSize);
//        Map<String, Object> map = new HashMap<String, Object>();
//        map.put("JobAndTrigger", jobAndTrigger);
//        map.put("number", jobAndTrigger.getTotalCount());
//        return map;
//    }
//}
//
